package com.john.springsecuritydemo.Controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 登录Controller
 * 日期 2021/6/2 18:50
 * 创建者：john driver
 */
@Controller
public class LoginController {

    /**
     * 页面跳转
     * @return
     */
    @PreAuthorize("hasRole('abc')")
    @PostMapping("/toMain")
    public String toMain(){
        System.out.println("执行登录方法");
        return "redirect:main.html";
    }
    @PostMapping("/toError")
    public String toError(){
        System.out.println("执行登录方法");
        return "redirect:error.html";
    }

    @RequestMapping("/demo")
    public String demo(){
        return "demo";
    }
    @RequestMapping("/showLogin")
    public String showLogin(){
        return "login";
    }
}
